package com.wcll.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wcll.bean.CQM_JianLi;

public class CQM_UpdateServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public CQM_UpdateServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out
				.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		out.print("    This is ");
		out.print(this.getClass());
		out.println(", using the GET method");
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		  response.setContentType("text/html; charset=UTF-8");
			request.setCharacterEncoding("UTF-8");
		CQM_JianLi jianli=new CQM_JianLi();
		String name=request.getParameter("name");
		String sex=request.getParameter("sex");
	    String email=request.getParameter("email");
		String phone=request.getParameter("phone");
	    String zhuzhi=request.getParameter("zhuzhi");
	    String shi=request.getParameter("hidden");
	    String sheng=request.getParameter("hidden1");
	    request.getSession().setAttribute("qq", sheng);
	    request.getParameter("id1");
	    String gongzi=request.getParameter("gongzi");
	    String desc=request.getParameter("desc");
	    String xuexiaoname=request.getParameter("xuexiaoname");
	    String zhuanyename=request.getParameter("zhuanyename");
	    String xueli=request.getParameter("xueli");
	    String waiyu=request.getParameter("waiyu");
	    String nengli=request.getParameter("nengli");
	    String jiangxiang=request.getParameter("jiangxiang");
	    String desc1=request.getParameter("desc1");
	    String shijianname=request.getParameter("shijianname");
	    String desc2=request.getParameter("desc2");
	    String  year=request.getParameter("year");
	     String month=request.getParameter("month");
	     String date=request.getParameter("date");
	     String date1=request.getParameter("date1");
	     String  year1=request.getParameter("year1");
	     String month1=request.getParameter("month1");
	     String date2=request.getParameter("date2");
	     String  year2=request.getParameter("year2");
	     String month2=request.getParameter("month2");
	     String date3=request.getParameter("date3");
	     String  year3=request.getParameter("year3");
	     String month3=request.getParameter("month3");
	    jianli.setXuexiaoname(xuexiaoname);
	     jianli.setZhuanyename(zhuanyename);
	     jianli.setXueli(xueli);
	     jianli.setWaiyu(waiyu);
	     jianli.setNengli(nengli);
	     jianli.setJiangxiang(jiangxiang);
	     jianli.setDesc1(desc1);
	     jianli.setShijianname(shijianname);
	     jianli.setDesc2(desc2);
	     jianli.setYear(year);
	     jianli.setMonth(month);
	     jianli.setDate(date);
	     jianli.setYear1(year1);
	     jianli.setMonth1(month1);
	     jianli.setDate1(date1);
	     jianli.setYear2(year2);
	     jianli.setMonth2(month2);
	     jianli.setDate2(date2);
	     jianli.setYear3(year3);
	     jianli.setMonth3(month3);
	     jianli.setDate3(date3);
	    jianli.setName(name);
	    jianli.setEmail(email);
	    jianli.setPhone(phone);
	    jianli.setSex(sex);
	    jianli.setZhuzhi(zhuzhi);
	    jianli.setSheng(sheng);
	    jianli.setShi(shi);
	    jianli.setGongzi(gongzi);
	     jianli.setDesc(desc);
	    try {jianli.Update(jianli);
	         jianli.Update1(jianli, request.getParameter("id1"));
	         jianli.Update2(jianli);
			 
			
			 this.getServletContext().getRequestDispatcher("/cqm_chaKan.jsp")
			 .forward(request, response);	
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
